package cn.edu.neu.lab603.cloudeval.strategy.policy

import cn.edu.neu.lab603.cloudeval.entity.PhysicalMachine

import scala.collection.mutable

/** 添加历史记录器。
  *
  * Created by yfwz100 on 2016/11/9.
  */
protected[policy] trait HistoryRecorder {

  protected val utilHistoryMap = new mutable.HashMap[Long, mutable.ListBuffer[Double]]
  protected val metricHistoryMap = new mutable.HashMap[Long, mutable.ListBuffer[Double]]

  protected def addHistoryEntry(host: PhysicalMachine, metric: Double): Unit = {
    utilHistoryMap.getOrElseUpdate(host.id, new mutable.ListBuffer[Double]) += host.getUsedResPct("mips")
    metricHistoryMap.getOrElseUpdate(host.id, new mutable.ListBuffer[Double]) += metric
  }

}
